package com.ruoyi.web.controller.degree;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.degree.domain.BizReserveExport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.degree.domain.BizReserve;
import com.ruoyi.degree.service.IBizReserveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约管理Controller
 *
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/degree/reserve")
@Api(tags = "预约信息API", description = "预约信息相关接口")
public class BizReserveController extends BaseController
{
    @Autowired
    private IBizReserveService bizReserveService;

    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(BizReserve bizReserve)
    {
        startPage();
        List<BizReserve> list = bizReserveService.selectBizReserveList(bizReserve);
        return getDataTable(list);
    }

    /**
     * 导出预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('degree:reserve:list')")
    @Log(title = "预约管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizReserveExport bizReserveExport)
    {
        List<BizReserveExport> list = bizReserveService.selectBizReserveExportList(bizReserveExport);
        ExcelUtil<BizReserveExport> util = new ExcelUtil<BizReserveExport>(BizReserveExport.class);
        util.exportExcel(response, list, "预约管理数据");
    }

    /**
     * 获取预约管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('degree:reserve:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizReserveService.selectBizReserveById(id));
    }

    /**
     * 新增预约管理
     */
    @PreAuthorize("@ss.hasPermi('degree:reserve:add')")
//    @Log(title = "预约管理", businessType = BusinessType.INSERT)
    @ApiOperation("新增预约信息")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BizReserve bizReserve)
    {
        return toAjax(bizReserveService.insertBizReserve(bizReserve));
    }

    /**
     * 修改预约管理
     */
    @PreAuthorize("@ss.hasPermi('degree:reserve:edit')")
    @Log(title = "预约管理", businessType = BusinessType.UPDATE)
    @PutMapping("edit")
    public AjaxResult edit(@RequestBody BizReserve bizReserve)
    {
        return toAjax(bizReserveService.updateBizReserve(bizReserve));
    }

    /**
     * 删除预约管理
     */
    @PreAuthorize("@ss.hasPermi('degree:reserve:remove')")
    @Log(title = "预约管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizReserveService.deleteBizReserveByIds(ids));
    }
}
